#Abrir o leitor de arquivos do excel
#Inserir o endere�o local do arquivo entre aspas ap�s read_excel

library(readxl)
graf_1 <- read_excel("~/.../graf_1.xlsx")
View(graf_1)

graf_2 <- read_excel("~/.../graf_2.xlsx")
View(graf_2)

graf_3 <- read_excel("~/.../graf_3.xlsx")
View(graf_3)


library(ggplot2)
library(ggrepel)


##GR�FICO 1 - PT

ggplot(graf_1, aes(col=conteudo))+
  geom_point(aes(ano,PT, col=conteudo), stat="identity")+
  geom_line(aes(ano,PT, col=conteudo), stat="identity")+
  geom_text_repel(aes(ano,PT,label=PT), position=position_dodge(.1), vjust=+1)+
  scale_x_continuous(breaks=c(2002, 2006, 2010, 2014, 2018))+
  ylim(c(0,100))+
  theme_bw()+
  theme(axis.text.y = element_blank(), axis.ticks.y=element_blank())+
  labs(title="Conte�do PT longitudinal (% do tempo)", fill="", x="", y="", caption="Fonte=Autores a partir de dados do CPOP")+
  theme(legend.position = "bottom")

##GR�FICO 2 - PSDB

ggplot(graf_1, aes(col=conteudo))+
  geom_point(aes(ano,PSDB, col=conteudo), stat="identity")+
  geom_line(aes(ano,PSDB, col=conteudo), stat="identity")+
  geom_text_repel(aes(ano,PSDB,label=PSDB), position=position_dodge(.1), vjust=+1)+
  scale_x_continuous(breaks=c(2002, 2006, 2010, 2014, 2018))+
  ylim(c(0,100))+
  theme_bw()+
  theme(axis.text.y = element_blank(), axis.ticks.y=element_blank())+
  labs(title="Conte�do PSDB longitudinal (% do tempo)",  fill="", x="", y="", caption="Fonte=Autores a partir de dados do CPOP")+
  theme(legend.position = "bottom")


##GR�FICO 3 - PT


ggplot(graf_2, aes(col=conteudo))+
  geom_point(aes(ano,PT, col=conteudo), stat="identity")+
  geom_line(aes(ano,PT, col=conteudo), stat="identity")+
  scale_x_continuous(breaks=c(2002, 2006, 2010, 2014, 2018))+
  geom_text_repel(aes(ano,PT,label=PT), position=position_dodge(.1), vjust=+1)+
  ylim(c(0,14))+
  theme_bw()+
  theme(axis.text.y = element_blank(), axis.ticks.y=element_blank())+
  labs(title="Conte�do PT longitudinal (% do tempo)",  fill="", x="", y="", caption="Fonte=Autores a partir de dados do CPOP")+
  theme(legend.position = "bottom")


##GR�FICO 4 - PSDB

ggplot(graf_2, aes(col=conteudo))+
  geom_point(aes(ano,PSDB, col=conteudo), stat="identity")+
  geom_line(aes(ano,PSDB, col=conteudo), stat="identity")+
  geom_text_repel(aes(ano,PSDB,label=PSDB), position=position_dodge(.1), vjust=+1)+
  scale_x_continuous(breaks=c(2002, 2006, 2010, 2014, 2018))+
  ylim(c(0,12))+
  theme_bw()+
  theme(axis.text.y = element_blank(), axis.ticks.y=element_blank())+
  labs(title="Conte�do PSDB longitudinal (% do tempo)", fill="", x="", y="", caption="Fonte=Autores a partir de dados do CPOP")+
  theme(legend.position = "bottom")


##GR�FICO 5 - PT

ggplot(graf_3, aes(col=conteudo))+
  geom_point(aes(ano,PT, col=conteudo), stat="identity")+
  geom_line(aes(ano,PT, col=conteudo), stat="identity")+
  geom_text_repel(aes(ano,PT,label=PT), position=position_dodge(.1), vjust=+1)+
  scale_x_continuous(breaks=c(2002, 2006, 2010, 2014, 2018))+
  ylim(c(0,100))+
  theme_bw()+
  theme(axis.text.y = element_blank(), axis.ticks.y=element_blank())+
  labs(title="Estrat�gias dos Partidos - PT - longitudinal (% do tempo)",  fill="", x="", y="", caption="Fonte=Autores a partir de dados do CPOP")+
  theme(legend.position = "bottom")


##GR�FICO 6 - PSDB

ggplot(graf_3, aes(col=conteudo))+
  geom_point(aes(ano,PSDB, col=conteudo), stat="identity")+
  geom_line(aes(ano,PSDB, col=conteudo), stat="identity")+
  geom_text_repel(aes(ano,PSDB,label=PSDB), position=position_dodge(.1), vjust=+1)+
  scale_x_continuous(breaks=c(2002, 2006, 2010, 2014, 2018))+
  ylim(c(0,100))+
  theme_bw()+
  theme(axis.text.y = element_blank(), axis.ticks.y=element_blank())+
  labs(title="Estrat�gias dos Partidos - PSDB - longitudinal (% do tempo)", fill="", x="", y="", caption="Fonte=Autores a partir de dados do CPOP")+
  theme(legend.position = "bottom")
